<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/layui/css/layui.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>

<script src="layui/layui.js"></script>

<body>
<center>
    <h2>添加商品信息</h2>

    <form class="layui-form" action="/goods/addGoods">
        <!--    <div class="layui-form-item">-->
        <!--        <label class="layui-form-label">用户账号</label>-->
        <!--        <div class="layui-input-block">-->
        <!--            <input id="id" type="text" name="id" lay-verify="title" autocomplete="on" class="layui-input">-->
        <!--        </div>-->
        <!--    </div>-->

        <div class="layui-form-item">
            <label class="layui-form-label">商品编号</label>
            <div class="layui-input-block">
                <input id="goodsId"  name="goodsId" lay-verify="title" autocomplete="on" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-block">
                <input id="goodsName" name="goodsName" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">类别标识</label>
            <div class="layui-input-block">
                <input id="categoryId" type="text" name="categoryId" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">图片</label>
            <div class="layui-input-block">
                <input id="picture" type="text" name="picture" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">销售价格</label>
            <div class="layui-input-block">
                <input id="salePrice" type="text" name="salePrice" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">剩余数量</label>
            <div class="layui-input-block">
                <input id="remainingCount" type="text" name="remainingCount" lay-verify="title" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-upload-drag" id="test10">
            <label class="layui-form-label">商品图片</label>
            <i class="layui-icon"></i>
            <p>点击上传，或将文件拖拽到此处</p>
            <div class="layui-hide" id="uploadDemoView">
                <hr>
                <img src="" alt="上传成功后渲染" style="max-width: 196px">
            </div>
        </div>

        <br>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>

    </form>

</center>
</body>

<!-- 引入jquery.js -->
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>

<script>

    // layui.use(['upload', 'element', 'layer'], function(){
    //     var $ = layui.jquery
    //         ,upload = layui.upload
    //         ,element = layui.element
    //         ,layer = layui.layer;
    //
    //     //拖拽上传
    //     upload.render({
    //         elem: '#test10'
    //         ,url: 'user/upload'
    //         ,done: function(res){
    //             layer.msg('上传成功');
    //             layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.msg);
    //             console.log(res)
    //         }
    //     });
    // });


    //Demo
    layui.use('form', function(){
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.msg(JSON.stringify(data.field));//把表单中数据转成Json并输出
            //可以写一些验证
            return true;//true表示执行action对应的地址
        });
    });
</script>


</html>